/**
*      author: Y_Yao
*      created: 2024-09-14 07:44:54
**/

#include<bits/stdc++.h>

using namespace std;
const int N = 2e5 + 9;
const int mod = 1e9 + 7;
using LL = long long;
int nums[N];
LL f[N];

LL pw(LL x, int n)
{
    LL ret = 1;
    while(n)
    {
        if( n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ret;
}

LL C(int n,int m)
{
    if( m > n) return 0;
    return f[n] * pw((f[m] * f[n-m]) % mod,mod - 2) % mod;
}

void solve()
{
    int n,k;
    cin>>n>>k;

    f[0] = 1;
    for(int i = 1;i <= n;i++)
    {
        f[i] = (f[i-1] * i) % mod;
    }

    int ones = 0;
    for(int i  = 0;i < n;i++)
    {
        cin >> nums[i];
        if(nums[i] == 1) ones++;
    }
    LL ret = 0;
    for(int i = (k + 1) / 2;i <= min(ones,k);i++)
    {
        ret += (C(ones,i) * C(n - ones,k - i)) % mod;
        ret = ret % mod;
    }
    cout<<ret<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 0;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}